<template>
  <div class="popular-container">
    <div class="popular-header">
      <div class="header-left">
        <h2 class="title">Postman Flows Gallery</h2>
        <p class="subtitle">Create custom workflows and connect APIs like never before with Postman Flows, providing an infinite canvas for easy arrangement and integration</p>
      </div>
      <a href="#" class="view-all">View all →</a>
    </div>

    <div class="collections-grid">
      <div
          v-for="collection in collections"
          :key="collection.id"
          class="collection-card"
      >
        <div class="card-header">
          <img
              :src="collection.icon"
              :alt="collection.title"
              class="collection-icon"
          />
          <div class="collection-info">
            <h3 class="collection-title">{{ collection.title }}</h3>
            <p class="collection-author">
              By {{ collection.author }}
              <span v-if="collection.verified" class="verified-badge">
                ✓
              </span>
            </p>
          </div>
        </div>

        <div class="collection-stats">
          <div class="stat-item">
            <i class="fork-icon">⑂</i>
            Fork {{ collection.forks }}
          </div>
          <div class="stat-item">
            <i class="view-icon">👁</i>
            {{ collection.views }}
          </div>
        </div>

        <div
            v-if="collection.weeklyForks"
            class="weekly-forks"
        >
          ↗ {{ collection.weeklyForks }} forks this week
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PopularCollections',
  data() {
    return {
      collections: [
        {
          id: 1,
          title: 'Slack Integration with Amazon',
          author: 'Postman',
          icon: 'icon/7.png',
          forks: '100+',
          verified: false,
          description: "This Flow is designed to allow you to integrate Slack to Amazon Alexa to streamline your developer productivity"
        },
        {
          id: 2,
          title: 'Update Notion Reading List',
          author: 'Postman',
          icon: 'icon/7.png',
          forks: '100+',
          verified: false,
          description: "Flow to update Notion Reading List with a random book from the New York Times bestsellers list"
        },
        {
          id: 3,
          title: 'Docusign Admin API',
          author: 'Postman',
          icon: 'icon/7.png',
          forks: '1k+',
          verified: true,
          description: "This Flow takes all invoices that are “Approved” In Zoho and generates them in Stripe and bills customers."
        }
      ]
    }
  }
}
</script>

<style scoped>
.popular-container {
  padding: 24px;
  background-color: #F5F5F5; /* 背景改为浅灰色 */
  color: #333333; /* 设置文本颜色为深灰色 */
  margin-left: 50px; /* 左边距 */
  margin-right: 50px; /* 右边距 */
}

.popular-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.header-left {
  flex: 1;
}

.title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #333333; /* 标题颜色改为深灰色 */
}

.subtitle {
  color: #666666; /* 副标题为浅灰色 */
  font-size: 14px;
}

.view-all {
  color: #4B9CDB;
  text-decoration: none;
}

.view-all:hover {
  color: #6BB0E7;
}

.collections-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 768px) {
  .collections-grid {
    grid-template-columns: 1fr;
  }
}

.collection-card {
  background-color: #FFFFFF; /* 背景颜色调整为白色 */
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* 添加阴影 */
  transition: background-color 0.3s;
}

.collection-card:hover {
  background-color: #F0F0F0; /* 悬浮时背景颜色变化为浅灰色 */
}

.card-header {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.collection-icon {
  width: 48px;
  height: 48px;
  border-radius: 4px;
}

.collection-info {
  flex: 1;
}

.collection-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #333333; /* 标题颜色为深灰色 */
}

.collection-author {
  color: #777777; /* 作者名字颜色变为灰色 */
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.verified-badge {
  color: #4B9CDB;
  font-weight: bold;
}

.collection-stats {
  display: flex;
  gap: 16px;
  color: #777777; /* 浅灰色 */
  font-size: 14px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.weekly-forks {
  margin-top: 16px;
  background-color: #6B46C1;
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
}

/* 确保图标垂直对齐 */
.fork-icon,
.view-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
</style>